<?php
include '../operations/connection.php';	
$a= (string)(microtime(true)*1000);
$b=split('\.',$a);
$idcomment= $b[0];

//$datecomment = NOW();
$idtestproject = $_REQUEST['idtestpro'];
$idemploy =$_REQUEST['idemp'];
$comment = $_REQUEST['comment'];

$stylecolor = $_REQUEST['stylecolor'];
$commentvalue= $comment."-%$#@!-#".$stylecolor;

$sqladdcomment = "insert into pr_comment(IDComment,IDTestProject,IDEmployee,`Comment`,DateComment)
 VALUES('$idcomment','$idtestproject','$idemploy','$commentvalue',NOW())";
mysql_query($sqladdcomment);

$querycomment = mysql_query("select c.IDComment,c.IDTestProject,c.IDEmployee,c.Comment,c.DateComment,
								 e.IDEmployee,e.FullName,c.IDTestProject from pr_comment c, employee e 
									 where c.IDEmployee = e.IDEmployee and c.IDTestProject = '$idtestproject' ORDER BY  c.DateComment ASC;")

?>


	                        <?php 
	                        if(count($querycomment)>0){
	                        	?>
	              <table style="width: 100%;">
	                        <?php  
		                        $vitri=0;
		                        while ($rowcoment = mysql_fetch_array($querycomment)){
		                        	$vitri++;
		                        		$idcomment = $rowcoment[IDComment];
		                        		$idemployeecomment = $rowcoment[IDEmployee];
										$stringcolor = substr($rowcoment[Comment],0,-14);
										$colorcomment = substr($rowcoment[Comment],-6);?>
									
							<tr id="mo" style="background: <?php if($vitri%2==0) 
															echo '#f2f9ff'; 
													else echo '#ffffff';?>; font-size: 13px;">
								<td class="rf-dt-c" style="padding: 0; vertical-align: middle; width: auto;">
	                        
		                        	<span style=" color:#b023ab; font-size: 13px;"><?php 
										switch ($colorcomment){
											case 'B023AB':
												?> <font color="#B023AB"><?php echo  " + ".$stringcolor ?> </font>
												<?php	break;
											case '424242':
												?> <font color="#424242"><?php echo  " + ".$stringcolor ?> </font> <?php	break;
											case '3DA850':
												?><font color="#3da850"><?php echo  " + ".$stringcolor ?> </font> <?php	break;
											case 'B02323':
												?><font color="#B02323"><?php echo  " + ".$stringcolor ?> </font> <?php	break;
											default:
												?> <font color="#424242"><?php echo  " + ".$stringcolor ?> </font> <?php break;
										}?>
									</span>
	                            	<i style="color:#424242; display:block; text-align:right; padding-top:5px;padding-right:15px; font-size: 13px;"><?php echo $rowcoment[FullName]." (".$rowcoment[DateComment].")"?></i>
	                           </td>
	                           <td class="rf-dt-c" style="width: 25px; vertical-align: middle; text-align: center;min-width: 80px">
		                          <?php 
									if($idemployeecomment==$idemploy){?>
		                           <a href="#" onclick="if(confirm('Are you sure?')){ delete_comment('<?=$idcomment?>','<?=$idtestproject?>','<?=$idemploy?>',this);return true}else{return false}">[ <?php echo "Delete"?> ]</a>
		                         <?php }else {}?>
							   </td>
						</tr>
	                   <?php }?>
	               </table>
	               <?php }?>
	               <?mysql_close($connection);?>
	                      
	